/*
 * ECajaForm.java
 *
 * Created on June 18, 2008, 10:04 AM
 */

package View;

import javax.swing.UIManager;
import com.birosoft.liquid.*;
import Controller.ECajaController;
import Model.Caja;
import Model.Congreso;
import Model.Gasto;
import Model.Ingreso;
import Model.Pedido;
import Reportes.gereraCaja;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import java.lang.Integer;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 *
 * @author  Gigin
 */
public class ECajaForm extends javax.swing.JFrame {

   // Controller del Form
    //tabla base para dibujar la tabla de pedidos
    private DefaultTableModel tablaBase;
    //tabla base para dibujar la tabla de gastos
    private DefaultTableModel tablaBase2;
    private DefaultTableModel tablaBase3;
    private Congreso congreso;
    private ECajaController ecc;
    private Caja caja;
    ArrayList<Gasto> gastos;
    ArrayList<Ingreso> ingresos;
    
  //Para manejar pantallas
    private PpalForm ppal; 
    private String modo;
    private ArrayList<Pedido> pedidoSeleccionado;
    /** Creates new form ECajaForm */
    public ECajaForm(String modo, Congreso cong) {
               
        this.setModo(modo);
        this.setCongreso(cong);
        
        //Se crea el controller de la pantalla
        ecc = new ECajaController();
        gastos = new ArrayList<Gasto>();
        // Se carga el Look and Feel
        try {
            UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");   
        } catch (Exception e) { }
          LiquidLookAndFeel.setStipples(false);
          LiquidLookAndFeel.setShowTableGrids(true);
          
        //Se crean los componentes del Form 
        initComponents();
      
        
        if (this.getModo().compareTo("Oficina") == 0){
             //se cargan congresos
                 ecc.cargarCongresos();
              //se cargan congresos en el combo
                 cargarComboCongresos();
         }else 
             if(this.getModo().compareTo("Congreso") == 0){
                 ecc.setCongreso(this.getCongreso());
                 jComboBox1.addItem(ecc.getCongreso());
                 jComboBox1.setEnabled(false);
                 jTextField1.setEnabled(false);
                 jButtonGuardar.setVisible(false);
            }
        
        
    }
    //* se cargan congresos en el combo*/
    public void cargarComboCongresos(){
         for (int i=0 ; i < ecc.getCongresos().size() ; i++)
             jComboBox1.addItem(ecc.getCongresos().get(i));  
         }
   //*se crea la tabla de pedidos en pantalla*/ 
private void buildTableModel(){
        tablaBase  = new DefaultTableModel(){
                      public boolean isCellEditable(int row, int column) { return false;}
         };
         
         
         tablaBase.addColumn("NúmeroPedido");
         tablaBase.addColumn("Cliente");
         tablaBase.addColumn("Total");
         tabItems.setModel(tablaBase);
         
         
         for (int i=0;i<tablaBase.getRowCount();i++){
             tablaBase.removeRow(i);
         }
        Vector tmp;
        ArrayList<Pedido> pedidos = ecc.actualizarCaja(congreso);
        pedidoSeleccionado = pedidos;
      for (int i=0; i<pedidos.size();i++)
        {
          if (pedidos.get(i).getSimbM().compareTo(jComboBox2.getSelectedItem().toString()) == 0){
            tmp= new Vector();
            tmp.add(pedidos.get(i).getNroPedido());
          tmp.add(pedidos.get(i).getCliente().getApellidoCli().toString()+" "+pedidos.get(i).getCliente().getNombreCli().toString());
          tmp.add(pedidos.get(i).getSimbM() + pedidos.get(i).getTotal());
              tablaBase.addRow(tmp);
          }
                     }
            
         tabItems.setModel(tablaBase);
                
    }
    //*se crea la tabla de gastos en pantalla*/
    private void buildTableModelDcha(){
        tablaBase2  = new DefaultTableModel(){
                      public boolean isCellEditable(int row, int column) { return false;}
         };
         ecc.cargarTipoGastos();
         ArrayList<String> mTipoGastos = ecc.getTipoGastos();
         tablaBase2.addColumn("Descripción");
         tablaBase2.addColumn("Tipo Gasto");
         tablaBase2.addColumn("Total");
         jTable2.setModel(tablaBase2);
         Vector tmp2;
        
         gastos = ecc.actualizarGastos(congreso); 
         for(int i=0; i<gastos.size();i++)
         {
         tmp2= new Vector();
         tmp2.add(gastos.get(i).getDescripcion());
         tmp2.add(mTipoGastos.get(Integer.parseInt(gastos.get(i).getTipo())-1));
         //Esto es una cholada pero funciona. Sino hay que pedir para cada uno el valor en la base.
         tmp2.add("$ " +gastos.get(i).getPrecio());       
         tablaBase2.addRow(tmp2);
         
         }
         
         jTable2.setModel(tablaBase2);
         
         tablaBase3  = new DefaultTableModel(){
                      public boolean isCellEditable(int row, int column) { return false;}
         };
         
         tablaBase3.addColumn("Descripción");
         tablaBase3.addColumn("Total");
         jTable3.setModel(tablaBase3);
         
         
         
         Vector tmp3;
         ingresos = ecc.actualizarIngresos(congreso); 
         for(int i=0; i<ingresos.size();i++)
         {
         tmp3= new Vector();
         tmp3.add(ingresos.get(i).getDescripcion());  
         tmp3.add("$ " +ingresos.get(i).getPrecio());       
         tablaBase3.addRow(tmp3);
         
         }
         
         jTable3.setModel(tablaBase3);
    }
    
    /** Se cargan los valores de los Jtextfields de la pantalla*/
    private void fillText(){
       Caja auxCaja= ecc.actualizarItemsCajas(congreso);
       JTextFieldVtas.setText(String.valueOf(auxCaja.getTotalVentas())); 
       JTextFieldVtas.setEnabled(false);
       jTextField3.setText(String.valueOf(auxCaja.getTotalGastos()));
       jTextField3.setEnabled(false);
       jTextFieldIngresos.setText(String.valueOf(auxCaja.getTotalIngresos()));
       jTextFieldIngresos.setEnabled(false);
       jTextField2.setText(String.valueOf(auxCaja.getVentasPendientes()));
       jTextField2.setEnabled(false);
       jTextField1.setText(String.valueOf(auxCaja.getSaldoInicial()));
    // jTextField1.setEnabled(false);
       jTextField5.setText(String.valueOf(auxCaja.getTotal()));
       jTextField5.setEnabled(false);
       jTextExtraccion.setText(String.valueOf(auxCaja.getExtracciones() * (-1)));
       jTextExtraccion.setEnabled(false);
       jTextField6.setText(String.valueOf(auxCaja.getAdelantos()));
       jTextField6.setEnabled(false);
        jTextFieldM2.setText(String.valueOf(auxCaja.getVentasM2()));
       jTextFieldM2.setEnabled(false);
        jTextFieldM3.setText(String.valueOf(auxCaja.getVentasM3()));
       jTextFieldM3.setEnabled(false);
    }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        jLabelFechaInicio = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabelFechaFin = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabelCiudad = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        JTextFieldVtas = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabItems = new javax.swing.JTable();
        jButtonGuardar = new javax.swing.JButton();
        jButtonVer = new javax.swing.JButton();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        jTextFieldIngresos = new javax.swing.JTextField();
        jTextFieldM3 = new javax.swing.JTextField();
        jTextFieldM2 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jButtonNuevoGasto = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jButtonVolver = new javax.swing.JButton();
        boton_Ingreso = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jTextExtraccion = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButtonVolver1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Monotype Corsiva", 1, 24));
        jLabel1.setForeground(new java.awt.Color(94, 148, 189));
        jLabel1.setText("Seleccionar una caja para comenzar");

        jComboBox1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jComboBox1MouseClicked(evt);
            }
        });
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jLabel23.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel23.setForeground(new java.awt.Color(94, 148, 189));
        jLabel23.setText("Fecha Inicio:");

        jLabelFechaInicio.setFont(new java.awt.Font("Verdana", 0, 10));

        jLabel24.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel24.setForeground(new java.awt.Color(94, 148, 189));
        jLabel24.setText("Fecha fin:");

        jLabelFechaFin.setFont(new java.awt.Font("Verdana", 0, 10));

        jLabel25.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel25.setForeground(new java.awt.Color(94, 148, 189));
        jLabel25.setText("Ciudad:");

        jLabelCiudad.setFont(new java.awt.Font("Verdana", 0, 10));

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/logo_GTV4.gif"))); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel9)
                .addGap(94, 94, 94)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelFechaInicio)
                        .addGap(42, 42, 42)
                        .addComponent(jLabel24)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelFechaFin)
                        .addGap(38, 38, 38)
                        .addComponent(jLabel25)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelCiudad))
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 407, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(355, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1)
                        .addGap(4, 4, 4)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel23)
                            .addComponent(jLabelFechaInicio)
                            .addComponent(jLabel24)
                            .addComponent(jLabelFechaFin)
                            .addComponent(jLabel25)
                            .addComponent(jLabelCiudad)))
                    .addComponent(jLabel9))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "CAJA", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 12), new java.awt.Color(94, 148, 189))); // NOI18N

        jLabel2.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel2.setText("Saldo Inicial: $");

        jLabel3.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel3.setText("Ventas Pendientes: $");

        jLabel4.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel4.setText("Gastos: $");

        jLabel5.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel5.setText("Ventas: $");

        jTextField1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTextField1MouseClicked(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel6.setText("Saldo Final: $");

        jLabel7.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel7.setForeground(new java.awt.Color(94, 148, 189));
        jLabel7.setText("LISTADO DE VENTAS");

        jScrollPane1.setFont(new java.awt.Font("Verdana", 0, 10));

        tabItems.setFont(new java.awt.Font("Verdana", 0, 10));
        tabItems.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Número Pedido", "Cliente", "Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tabItems);

        jButtonGuardar.setBackground(new java.awt.Color(94, 148, 189));
        jButtonGuardar.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonGuardar.setForeground(new java.awt.Color(94, 148, 189));
        jButtonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Guardar_normal.gif"))); // NOI18N
        jButtonGuardar.setToolTipText("Modificar saldo inicial");
        jButtonGuardar.setBorderPainted(false);
        jButtonGuardar.setContentAreaFilled(false);
        jButtonGuardar.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Guardar_deshabilitado.gif"))); // NOI18N
        jButtonGuardar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Guardar_presionado.gif"))); // NOI18N
        jButtonGuardar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Guardar_mouse.gif"))); // NOI18N
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jButtonVer.setText("Ver");
        jButtonVer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVerActionPerformed(evt);
            }
        });

        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel11.setText("Ingresos:$");

        jLabel12.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel12.setText("Ventas Mon3");

        jLabel13.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel13.setText("Ventas Mon2");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel2)
                            .addComponent(jLabel5)
                            .addComponent(jLabel11)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(65, 65, 65)
                        .addComponent(jComboBox2, 0, 86, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(JTextFieldVtas, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                    .addComponent(jTextField3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldIngresos, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldM3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldM2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(63, 63, 63))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(129, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(201, 201, 201)
                .addComponent(jButtonVer)
                .addContainerGap(280, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel2)
                                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(6, 6, 6)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel3)
                                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel4)
                                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jTextFieldM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel13))
                                .addGap(18, 18, 18)))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(jTextFieldIngresos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(JTextFieldVtas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonVer)
                        .addGap(40, 40, 40))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldM3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))
                        .addGap(455, 455, 455))))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "GASTOS", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 12), new java.awt.Color(94, 148, 189))); // NOI18N

        jTable2.setFont(new java.awt.Font("Verdana", 0, 10));
        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Descripción", "Total"
            }
        ));
        jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable2MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jTable2);

        jButtonNuevoGasto.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonNuevoGasto.setForeground(new java.awt.Color(94, 148, 189));
        jButtonNuevoGasto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/NuevoIng_normal.gif"))); // NOI18N
        jButtonNuevoGasto.setToolTipText("Ingresar un nuevo gasto");
        jButtonNuevoGasto.setBorderPainted(false);
        jButtonNuevoGasto.setContentAreaFilled(false);
        jButtonNuevoGasto.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/NuevoIng_deshabilitado.gif"))); // NOI18N
        jButtonNuevoGasto.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/NuevoIng_presionado.gif"))); // NOI18N
        jButtonNuevoGasto.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/NuevoIng_mouse.gif"))); // NOI18N
        jButtonNuevoGasto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNuevoGastoActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel8.setForeground(new java.awt.Color(94, 148, 189));
        jLabel8.setText("LISTADO DE GASTOS");

        jButtonVolver.setFont(new java.awt.Font("Verdana", 1, 10)); // NOI18N
        jButtonVolver.setForeground(new java.awt.Color(94, 148, 189));
        jButtonVolver.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_normal.gif"))); // NOI18N
        jButtonVolver.setToolTipText("Volver a la pantalla anterior");
        jButtonVolver.setBorderPainted(false);
        jButtonVolver.setContentAreaFilled(false);
        jButtonVolver.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_deshabilitado.gif"))); // NOI18N
        jButtonVolver.setFocusPainted(false);
        jButtonVolver.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_presionado.gif"))); // NOI18N
        jButtonVolver.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_mouse.gif"))); // NOI18N
        jButtonVolver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVolverActionPerformed(evt);
            }
        });

        boton_Ingreso.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/NuevoGasto_normal.gif"))); // NOI18N
        boton_Ingreso.setToolTipText("Ingresar un nuevo Gasto");
        boton_Ingreso.setBorderPainted(false);
        boton_Ingreso.setContentAreaFilled(false);
        boton_Ingreso.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/NuevoGasto_deshabilitado.gif"))); // NOI18N
        boton_Ingreso.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/NuevoGasto_presionado.gif"))); // NOI18N
        boton_Ingreso.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Cajas/NuevoGasto_mouse.gif"))); // NOI18N
        boton_Ingreso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_IngresoActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel10.setForeground(new java.awt.Color(94, 148, 189));
        jLabel10.setText("LISTADO DE INGRESOS");

        jTable3.setFont(new java.awt.Font("Verdana", 0, 10));
        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Descripción", "Total"
            }
        ));
        jTable3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable3MouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jTable3);

        jTextExtraccion.setEditable(false);

        jTextField6.setEditable(false);

        jButton1.setText("Extracción");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Adelanto");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButtonVolver1.setFont(new java.awt.Font("Verdana", 1, 10)); // NOI18N
        jButtonVolver1.setForeground(new java.awt.Color(94, 148, 189));
        jButtonVolver1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Excel_normal.gif"))); // NOI18N
        jButtonVolver1.setToolTipText("Volver a la pantalla anterior");
        jButtonVolver1.setBorderPainted(false);
        jButtonVolver1.setContentAreaFilled(false);
        jButtonVolver1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Excel_deshabilitado.gif"))); // NOI18N
        jButtonVolver1.setFocusPainted(false);
        jButtonVolver1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Excel_presionado.gif"))); // NOI18N
        jButtonVolver1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Excel_mouse.gif"))); // NOI18N
        jButtonVolver1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVolver1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(147, 147, 147)
                        .addComponent(jLabel8))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(148, 148, 148)
                        .addComponent(jLabel10))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(54, 54, 54)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(jButtonNuevoGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(boton_Ingreso, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextExtraccion, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jButton1))))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jButtonVolver1, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(51, 51, 51)
                                .addComponent(jButtonVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(313, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(boton_Ingreso, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextExtraccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonNuevoGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton2)))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jButtonVolver1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jButtonVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(64, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(375, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(385, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jTextField1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextField1MouseClicked
    //jTextField1.setEnabled(true);
   
}//GEN-LAST:event_jTextField1MouseClicked

/** Acciones cuando se presiona el boton "Modificar saldo"*/
private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
   if(ecc.esSaldo(jTextField1.getText()))
   {
    caja=new Caja();
    Caja auxCaja= ecc.actualizarItemsCajas(congreso);
    caja.setSaldoInicial(Float.parseFloat(jTextField1.getText().toString()));
    caja.setGasto(auxCaja.getGasto());
    caja.setTotal(auxCaja.getTotal());
    caja.setTotalGastos(auxCaja.getTotalGastos());
    caja.setTotalVentas(auxCaja.getTotalVentas());
    caja.setVentasPendientes(auxCaja.getVentasPendientes());
    congreso.setCaja(caja);
    
    ecc.actualizarSaldoIni(congreso);
   // jTextField1.setEnabled(false);
    fillText();
     JOptionPane.showMessageDialog(new JFrame(), "Saldo modificado correctamente "," ", JOptionPane.INFORMATION_MESSAGE);
   }
   
}//GEN-LAST:event_jButtonGuardarActionPerformed

private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
   // congreso = new Congreso();
    congreso = (Congreso)jComboBox1.getSelectedItem();
    ecc.setCongreso(congreso);
    
    
    //Carga el combo de Monedas del Congreso seleccionado.
    
    jComboBox2.removeAllItems();
    
    if (congreso.getIniciales().compareTo("OFICE") == 0){
         ecc.cargarMonedas();
         ecc.cargadatosCombo(jComboBox2, ecc.getMonedas());
         }else{
    jComboBox2.addItem(congreso.getSimbM1());
    jComboBox2.addItem(congreso.getSimbM2());
    jComboBox2.addItem(congreso.getSimbM3());
         }
    // Se muestra el nombre del congreso seleccionado en la pantalla
    
    String diaI = congreso.getFechaInicio().substring(8, 10);  
    String mesI = congreso.getFechaInicio().substring(5, 7);
    String anioI = congreso.getFechaInicio().substring(0, 4);
    String fechaI = diaI+"/"+mesI+"/"+anioI;
    
    String diaF = congreso.getFechaFin().substring(8, 10);  
    String mesF = congreso.getFechaFin().substring(5, 7);
    String anioF = congreso.getFechaFin().substring(0, 4);
    String fechaF = diaF+"/"+mesF+"/"+anioF;
    
    jLabel1.setText(congreso.getNombreCong());
    jLabelFechaInicio.setText(fechaI);
    jLabelFechaFin.setText(fechaF);
    jLabelCiudad.setText(congreso.getLocalidad());
    
    buildTableModelDcha();
        fillText();   

}//GEN-LAST:event_jComboBox1ActionPerformed

private void jComboBox1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBox1MouseClicked
    congreso = new Congreso();
    congreso = (Congreso)jComboBox1.getSelectedItem();
    ecc.setCongreso(congreso);
    
    jComboBox2.removeAllItems();
    jComboBox2.addItem(congreso.getSimbM1());
    jComboBox2.addItem(congreso.getSimbM2());
    jComboBox2.addItem(congreso.getSimbM3());
    
    // Se muestra el nombre del congreso seleccionado en la pantalla
    jLabel1.setText(congreso.getNombreCong());
    //buildTableModel();
        
 
}//GEN-LAST:event_jComboBox1MouseClicked

private void jButtonVolverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVolverActionPerformed
     ppal.cargarFormulario();
     this.dispose();
}//GEN-LAST:event_jButtonVolverActionPerformed

private void jButtonNuevoGastoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNuevoGastoActionPerformed

    
    IngresoForm iForm = new IngresoForm(this, true, 0);
    iForm.setCongreso(ecc.getCongreso());
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    iForm.setLocation(screenWidth / 4, screenHeight / 4);
    iForm.setVisible(true);    
}//GEN-LAST:event_jButtonNuevoGastoActionPerformed

private void boton_IngresoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_IngresoActionPerformed
    
    GastoForm gForm = new GastoForm(this, true);
    gForm.setCongreso(ecc.getCongreso());
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    gForm.setLocation(screenWidth / 4, screenHeight / 4);
    
    gForm.setVisible(true);
}//GEN-LAST:event_boton_IngresoActionPerformed

private void jButtonVerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVerActionPerformed
    try{
    boolean res = true;
    int val = (Integer)tablaBase.getValueAt(tabItems.getSelectedRow(), 0);
    Pedido Nuevo = null;
    
    for (int i=0; i<pedidoSeleccionado.size();i++){
        String Nombre = pedidoSeleccionado.get(i).getCliente().getApellidoCli().toString()+" "+pedidoSeleccionado.get(i).getCliente().getNombreCli().toString();
        if (Nombre.compareTo((String)tablaBase.getValueAt(tabItems.getSelectedRow(), 1))==0){
            if (pedidoSeleccionado.get(i).getNroPedido() == val){
                Nuevo = new Pedido();
                Nuevo = pedidoSeleccionado.get(i);
                try{
                Nuevo.setCongreso(pedidoSeleccionado.get(i).getCongreso());
                System.out.println(pedidoSeleccionado.get(i).getCongreso().getNombreCong());
                //Con esta impresion cuando la asignacion de arriba 
                //no la puede hacer agarra por el catch y hace lo que quiero. asique queda asi
                }catch(Exception e){
                    Nuevo.setCongreso(congreso);
                }
                res = true;
            }
        }
    }
    if (res){
        FichaPedidos ficha = new FichaPedidos(this, true, Nuevo);
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    ficha.setLocation(screenWidth / 4, screenHeight / 4);
        ficha.setVisible(true);
    }
    }catch(Exception e){
        JOptionPane.showMessageDialog(new JFrame(), "Debe seleccionar un pedido"," ", JOptionPane.INFORMATION_MESSAGE);
    }
}//GEN-LAST:event_jButtonVerActionPerformed

private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        try{
        buildTableModel();
        buildTableModelDcha();
        fillText();
        }catch(Exception e){}
}//GEN-LAST:event_jComboBox2ActionPerformed

private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
    Object[] opciones ={"Si","No"}; 
    int selec;
    selec = JOptionPane.showOptionDialog(new JFrame(), "¿Está seguro que desea eliminar el Gasto?\n" + jTable2.getValueAt(jTable2.getSelectedRow(), 0),"Atención!",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, opciones, null);
             if(selec == 0){
                
                System.out.println(gastos.get(jTable2.getSelectedRow()).getFecha());
                System.out.println(gastos.get(jTable2.getSelectedRow()).getDescripcion());
                //jTable2.removeRowSelectionInterval(jTable2.getSelectedRow(), jTable2.getSelectedRow()+1);
                if (ecc.eliminaGasto(gastos.get(jTable2.getSelectedRow()).getFecha())){
                    JOptionPane.showMessageDialog(new JFrame(), "El gasto se ha eliminado"," ", JOptionPane.INFORMATION_MESSAGE);
                }else{
                    JOptionPane.showMessageDialog(new JFrame(), "Ha ocurrido un error. Inténtelo de nuevo."," ", JOptionPane.INFORMATION_MESSAGE);
                }
                buildTableModelDcha();
                fillText();
                //jTable2.remo
                //ecc.actualizarGastos(congreso);
             }
    
}//GEN-LAST:event_jTable2MouseClicked

private void jTable3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable3MouseClicked
    Object[] opciones ={"Si","No"}; 
    int selec;
    selec = JOptionPane.showOptionDialog(new JFrame(), "¿Está seguro que desea eliminar el Ingreso?\n" + jTable3.getValueAt(jTable3.getSelectedRow(), 0),"Atención!",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, opciones, null);
             if(selec == 0){
                
                System.out.println(ingresos.get(jTable3.getSelectedRow()).getFecha());
                System.out.println(ingresos.get(jTable3.getSelectedRow()).getDescripcion());
                //jTable2.removeRowSelectionInterval(jTable2.getSelectedRow(), jTable2.getSelectedRow()+1);
                if (ecc.eliminaIngreso(ingresos.get(jTable3.getSelectedRow()).getFecha())){
                    JOptionPane.showMessageDialog(new JFrame(), "El Ingreso se ha eliminado"," ", JOptionPane.INFORMATION_MESSAGE);
                }else{
                    JOptionPane.showMessageDialog(new JFrame(), "Ha ocurrido un error. Inténtelo de nuevo."," ", JOptionPane.INFORMATION_MESSAGE);
                }
                buildTableModelDcha();
                fillText();
             }
}//GEN-LAST:event_jTable3MouseClicked

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    IngresoForm iForm = new IngresoForm(this, true, 1);//1 porque es una extraccion
    iForm.setCongreso(ecc.getCongreso());
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    iForm.setLocation(screenWidth / 4, screenHeight / 4);
    iForm.setVisible(true);
    
    
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    IngresoForm iForm = new IngresoForm(this, true, 2);//Es 3 porque es un adelanto
    iForm.setCongreso(ecc.getCongreso());
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    iForm.setLocation(screenWidth / 4, screenHeight / 4);
    iForm.setVisible(true);
}//GEN-LAST:event_jButton2ActionPerformed

private void jButtonVolver1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVolver1ActionPerformed
ecc.congreso.setCaja(ecc.caja);
gereraCaja gc=new gereraCaja(ecc.congreso,ecc.gastos,ecc.ingresos,ecc.pedidos);
gc.generaReporte();
JOptionPane.showMessageDialog(new JFrame(), "Informe Caja"+ecc.congreso.getIniciales()+".xls generado"," ", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jButtonVolver1ActionPerformed

public void actualizar(){
  buildTableModelDcha();
  fillText();
  //this.jButton4.setEnabled(false);  
}



public Congreso getCongreso(){
        return congreso;
    }
    
    public void setCongreso(Congreso val){
        this.congreso = val;
    } 


public String getModo() {
        return modo;
    }
    
public void setModo (String val) {
        this.modo = val;
    }

public void setPpal(PpalForm p){
       this.ppal=p;
}


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField JTextFieldVtas;
    private javax.swing.JButton boton_Ingreso;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonNuevoGasto;
    private javax.swing.JButton jButtonVer;
    private javax.swing.JButton jButtonVolver;
    private javax.swing.JButton jButtonVolver1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelCiudad;
    private javax.swing.JLabel jLabelFechaFin;
    private javax.swing.JLabel jLabelFechaInicio;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTextField jTextExtraccion;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextFieldIngresos;
    private javax.swing.JTextField jTextFieldM2;
    private javax.swing.JTextField jTextFieldM3;
    private javax.swing.JTable tabItems;
    // End of variables declaration//GEN-END:variables

}
